home *** CD-ROM | disk | FTP | other *** search
- Path: uunet!zephyr.ens.tek.com!tekred!saab!billr
- From: billr@saab.CNA.TEK.COM (Bill Randle)
- Newsgroups: comp.sources.games
- Subject: v11i046: gb3 - Galactic Bloodshed, an empire-like war game [Ver. 2.0], Patch2h
- Message-ID: <6233@tekred.CNA.TEK.COM>
- Date: 28 Aug 90 19:36:33 GMT
- Sender: news@tekred.CNA.TEK.COM
- Lines: 2101
- Approved: billr@saab.CNA.TEK.COM
-
- Submitted-by: VANCLEEF@mps.ohio-state.edu
- Posting-number: Volume 11, Issue 46
- Archive-name: gb3/Patch2h
- Patch-To: gb3: Volume 10, Issue 1-14
-
-
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 8 (of 9)."
- # Contents: client/cmd.c server/capture.c server/cs.c server/declare.c
- # server/land.c server/launch.c server/scrap.c server/ships.h
- # Wrapped by billr@saab on Tue Aug 28 08:54:59 1990
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'client/cmd.c' -a "${1}" != "-c" ; then
- echo shar: Renaming existing file \"'client/cmd.c'\" to \"'client/cmd.c.orig'\"
- mv -f 'client/cmd.c' 'client/cmd.c.orig'
- fi
- echo shar: Extracting \"'client/cmd.c'\" \(1462 characters\)
- sed "s/^X//" >'client/cmd.c' <<'END_OF_FILE'
- X/* cmd.c -- client commands. so far, 'source <file>'
- X * copyright (C) Robert Chansky, 1990. See the disclaimer in the GB server
- X * for copyright information.
- X */
- X
- X#include <string.h>
- X#include <stdio.h>
- X
- X/* return '1' if this was, in fact, a client-recognized command. */
- X
- Xint client_cmd(cmd)
- Xchar *cmd;
- X{
- Xchar *c;
- X
- X c=cmd;
- X while (*c!='\0' && *c!=' ' && *c!='\t') c++; /* skip over command */
- X while (*c==' ' || *c=='\t') c++; /* skip over ws */
- X
- X if (!strncmp(cmd, "source", strlen("source"))) {
- X source(c); /* the rest is the filename argument */
- X return 1;
- X } else if (!strncmp(cmd, "script", strlen("script"))) {
- X script(c);
- X return 1;
- X } else
- X return 0;
- X
- X}
- X
- X/* "script" (send output to) a file */
- Xscript(file)
- Xchar* file;
- X{
- X
- X}
- X
- X
- X/* "source" the file, if the file exists. */
- X
- Xsource(file)
- Xchar *file;
- X{
- XFILE *sourcefd;
- Xint c,i=0,j=1;
- Xchar sourcein[1024], *nn;
- X
- X if ((nn = rindex(file, '\n'))!=NULL) /* remove '\n' from file name */
- X *nn = '\0';
- X
- X if (file=='\0') {
- X printf("usage: source <file>\n");
- X return;
- X }
- X
- X if ((sourcefd = fopen(file, "r"))==NULL) {
- X printf("error opening file '%s'\n",file);
- X return;
- X }
- X
- X printf("sourceing file '%s'\n",file);
- X
- X /* get a line of input and send to GB */
- X do {
- X do {
- X c=fgetc(sourcefd);
- X sourcein[i++] = c;
- X } while (c != '\n' && c!=EOF);
- X sourcein[i] = '\0'; sourcein[i+1] = '\0';
- X
- X printf("%d: '%s'\n", j, sourcein);
- X transmit(sourcein, i+1);
- X i = 0;
- X j++;
- X
- X } while (c!=EOF);
- X
- X fclose(sourcefd);
- X
- X}
- END_OF_FILE
- if test 1462 -ne `wc -c <'client/cmd.c'`; then
- echo shar: \"'client/cmd.c'\" unpacked with wrong size!
- fi
- # end of 'client/cmd.c'
- if test -f 'server/capture.c' -a "${1}" != "-c" ; then
- echo shar: Renaming existing file \"'server/capture.c'\" to \"'server/capture.c.orig'\"
- mv -f 'server/capture.c' 'server/capture.c.orig'
- fi
- echo shar: Extracting \"'server/capture.c'\" \(8187 characters\)
- sed "s/^X//" >'server/capture.c' <<'END_OF_FILE'
- X/*
- X** Galactic Bloodshed, copyright (c) 1989 by Robert P. Chansky,
- X** smq@ucscb.ucsc.edu, mods by people in GB_copyright.h.
- X** Restrictions in GB_copyright.h.
- X**
- X** capture.c -- capture a ship on the ground
- X**
- X*/
- X
- X#include "GB_copyright.h"
- X#define EXTERN extern
- X#include "vars.h"
- X#include "ships.h"
- X#include "races.h"
- X#include "buffers.h"
- X#include <signal.h>
- X#include <math.h>
- X#include <signal.h>
- X
- Xint capture_sectdata,capture_shdata,capture_pdata, capture_racedata;
- X
- Xextern int Defensedata[];
- X
- X
- Xcapture(Playernum,APcount, argn,args)
- Xint Playernum;
- Xint APcount;
- Xint argn;
- Xchar args[MAXARGS][COMMANDSIZE];
- X{
- Xshiptype *ship;
- Xplanettype *p;
- Xsectortype *sect;
- Xboolean Land=0,Dock=0,cont,planetmod=0,sectmod=0;
- Xint boarders,olddpopn,oldapopn,oldowner,shipdam,booby,pris,
- X numdest=0,shipno,x= -1,y= -1,i,mask, casualties, casualties2, casualty_scale;
- Xfloat astrength,dstrength;
- Xracetype *Race, *alien;
- X
- Xcapture_sectdata = capture_shdata = capture_pdata = NEUTRAL_FD;
- X
- Xsscanf(args[1]+(args[1][0]=='#'), "%d",&shipno);
- X
- X openshdata(&capture_shdata);
- X if (!getship(capture_shdata, &ship, shipno)) {
- X sprintf(buf,"Ship doesn't exist.\n");
- X notify(Playernum, buf);
- Xclose(capture_shdata);
- X return;
- X }
- Xclose(capture_shdata);
- X
- X if (!ship->is_alive || !(ship->is_docked && ship->whatdest==LEVEL_PLAN) ) {
- X sprintf(buf,"%s #%d is not landed on a planet.\n",
- X Shipnames[ship->type], shipno);
- X notify(Playernum, buf);
- X free(ship);
- X return;
- X }
- X
- X if (ship->owner==Playernum) {
- X sprintf(buf,"That's your own ship.\n");
- X notify(Playernum, buf);
- X free(ship);
- X return;
- X }
- X
- X
- X if (!enufAP(Playernum,Stars[ship->storbits]->AP[Playernum-1], APcount)) {
- X free(ship);
- X return;
- X }
- X
- Xx = (int)ship->xpos;
- Xy = (int)ship->ypos;
- X
- X openpdata(&capture_pdata);
- X getplanet(capture_pdata, &p, Stars[ship->storbits]->planetpos[ship->pnumorbits]);
- X close_file(capture_pdata);
- X
- X opensectdata(&capture_sectdata);
- X getsector(capture_sectdata,§,
- X p->sectormappos+(y*p->Maxx+x)*sizeof(sectortype));
- X
- X if (sect->owner!=Playernum) {
- X sprintf(buf,"You don't own the sector where the ship is landed.\n");
- X notify(Playernum, buf);
- X free(sect);
- X free(p);
- X free(ship);
- X return;
- X }
- X
- Xif(argn<2)
- X boarders = sect->popn;
- Xelse
- X boarders = atoi(args[2]);
- X
- X if (boarders > sect->popn || boarders <= 0) {
- X sprintf(buf,"Illegal number of boarders (max can be %d).\n",
- X sect->popn);
- X notify(Playernum, buf);
- X free(ship);
- X free(sect);
- X free(p);
- X return;
- X }
- X
- X openracedata(&capture_racedata);
- X getrace(capture_racedata, &Race, Playernum);
- X close_file(capture_racedata);
- X
- X openracedata(&capture_racedata);
- X getrace(capture_racedata, &alien, (int)ship->owner);
- X close_file(capture_racedata);
- X
- X if (isset(Race->allied, ship->owner))
- X {
- X sprintf(buf,"Boarding the ship of your ally, %s\n", alien->name);
- X notify(Playernum, buf);
- X }
- X
- X oldapopn = boarders;
- X olddpopn = ship->popn;
- X oldowner = ship->owner;
- X shipdam = 0;
- X casualties = 0;
- X casualties2 = 0;
- X
- X if(olddpopn || !Max_crew(ship)) {
- X
- X sprintf(buf,"Attack strength: %.2f Defense strength: %.2f\n",
- X astrength = (float)boarders * (float)Race->fighters
- X * .01 * Race->tech
- X * (Race->likes[sect->des] + 0.01)
- X * ((sect->is_wasted ? 0.0 : (float)Defensedata[sect->des]) + 1.0),
- X
- X dstrength = (Max_crew(ship) ? (float)ship->popn * (float)alien->fighters : 1)
- X * .01 * alien->tech
- X * ((float)Armor(ship) + 0.01)
- X * .01 * (100.0 - (float)ship->damage));
- X
- X notify(Playernum, buf);
- X
- X sect->popn -= boarders;
- X booby = 0;
- Xcasualty_scale = MIN(boarders, ship->popn + ship->destruct);
- X
- Xif(astrength > 0.0)
- X casualties = int_rand(0, round_rand((float)casualty_scale * (dstrength+1.0) /
- X (astrength+1.0)));
- X
- Xif(dstrength > 0.0) {
- X casualties2 = int_rand(0, round_rand((float)casualty_scale * (astrength+1.0) /
- X (dstrength+1.0)));
- X
- X shipdam = int_rand(0,round_rand(25. * (astrength+1.0)/(dstrength+1.0)));
- X ship->damage = MIN(100, ship->damage+shipdam);
- X
- X if(!Max_crew(ship) && ship->destruct) { /* booby trapped robot ships */
- X casualties += int_rand(0, 10*ship->destruct);
- X booby = int_rand(0, 10*ship->destruct);
- X booby = MIN(100, booby);
- X shipdam += booby;
- X ship->damage += booby;
- X }
- X
- X
- X if(ship->damage >= 100)
- X kill_ship(Playernum, ship);
- X
- X }
- X
- X casualties = MIN(boarders, casualties);
- X boarders -= casualties;
- X
- X casualties2 = MIN(olddpopn, casualties2);
- X ship->popn -= casualties2;
- X ship->mass -= casualties2 * alien->mass;
- X
- X }
- X
- X if (!ship->popn && ship->is_alive) {
- X /* we got 'em */
- X ship->owner = Playernum;
- X ship->popn = MIN(boarders, Max_crew(ship));
- X sect->popn += boarders - ship->popn;
- X /* return excess boarders home */
- X ship->mass += ship->popn * Race->mass; /* our mass */
- X } else { /* retreat */
- X sect->popn += boarders;
- X }
- X
- X if(!sect->popn)
- X sect->owner = 0;
- X
- X sprintf(buf,"BULLETIN from %s/%s!!\n",
- X Stars[ship->storbits]->name,Stars[ship->storbits]->pnames[ship->pnumorbits]);
- X notify(oldowner, telegram_buf);
- X sprintf(buf,"You are being attacked by%s Player #%d (%s)!!!\n",
- X (isset(alien->allied,Playernum) ? " your ally" :
- X (isset(alien->atwar,Playernum) ? " your enemy" : " neutral")),
- X Playernum,Race->name);
- X notify(oldowner, buf);
- X sprintf(buf,"%s #%d ASSAULTED at sector %d,%d [owner %d] !\n",
- X Shipnames[ship->type], shipno, x, y, sect->owner);
- X notify(oldowner, buf);
- X
- Xif(booby) {
- X sprintf(buf,"Booby trap triggered causing %d%% damage.\n", booby);
- X notify(oldowner, buf);
- X notify(Playernum, buf);
- X}
- X
- Xif(shipdam) {
- X sprintf(buf,"Total damage: %d%% (now %d%%)\n", shipdam, ship->damage);
- X notify(oldowner, buf);
- X sprintf(buf,"Damage inflicted: Them: %d%% (now %d%%)\n",
- X shipdam,ship->damage);
- X notify(Playernum, buf);
- X }
- X
- X if(!ship->is_alive) {
- X sprintf(buf," YOUR SHIP WAS DESTROYED!!!\n");
- X notify(oldowner, buf);
- X sprintf(buf," Their ship DESTROYED!!!\n");
- X notify(Playernum, buf);
- X }
- X
- X if (ship->owner==Playernum) {
- X sprintf(buf,"%s CAPTURED!\n",Shipnames[ship->type]);
- X notify(oldowner, buf);
- X sprintf(buf,"VICTORY! The ship is yours!\n");
- X notify(Playernum, buf);
- X if ((astrength+1.0)/(dstrength+1.0) > 5.0 && olddpopn) {
- X pris=astrength/dstrength;
- X pris=MIN(pris,olddpopn);
- X if (Race->captured_prisoners[oldowner-1]<100) {
- X Race->captured_prisoners[oldowner-1] +=
- X pris;
- X sprintf(buf,"%d prisoner%s captured!\n",
- X pris, ((pris>1) ? "s" : ""));
- X notify(Playernum, buf);
- X notify(oldowner, buf);
- X }
- X }
- X
- X if (ship->popn)
- X {
- X sprintf(buf,"%d boarders move in.\n",
- X MIN(boarders, ship->popn));
- X notify(Playernum, buf);
- X }
- X } else if(ship->popn) {
- X sprintf(buf,"You fought them off!\n");
- X notify(oldowner, buf);
- X sprintf(buf,"The boarding was repulsed; try again.\n");
- X notify(Playernum, buf);
- X }
- X
- X if (ship->is_alive) {
- X if (sect->popn + boarders == 0) {
- X sprintf(buf,"You killed all the aliens in this sector!\n");
- X notify(oldowner, buf);
- X } else sprintf(buf," ");
- X if (boarders==0) {
- X sprintf(buf,"Oh no! They killed your party to the last man!\n");
- X notify(Playernum, buf);
- X }
- X } else {
- X sprintf(buf,"Your ship was weakened too much!\n");
- X notify(oldowner, buf);
- X sprintf(buf,"The assault weakened their ship too much!\n");
- X notify(Playernum, buf);
- X }
- X
- Xif(casualties || casualties2) {
- Xsprintf(buf,"Casualties: Yours: %d, Theirs: %d\n", casualties2, casualties);
- X notify(oldowner, buf);
- X sprintf(buf,"Casualties: Yours: %d, Theirs: %d\n", casualties, casualties2);
- X notify(Playernum, buf);
- X}
- X openshdata(&capture_shdata);
- X putship(capture_shdata, ship, shipno);
- X close_file(capture_shdata);
- X
- X putsector(capture_sectdata,sect,p->sectormappos+(y*p->Maxx+x)*sizeof(sectortype));
- X close_file(capture_sectdata);
- X
- X deductAPs(Playernum, APcount, ship->storbits, 0);
- X
- X openracedata(&capture_racedata);
- X putrace(capture_racedata, Race);
- X close_file(capture_racedata);
- X
- X
- X free(alien);
- X free(Race);
- X free(p);
- X free(ship);
- X free(sect);
- X
- X}
- X
- END_OF_FILE
- if test 8187 -ne `wc -c <'server/capture.c'`; then
- echo shar: \"'server/capture.c'\" unpacked with wrong size!
- fi
- # end of 'server/capture.c'
- if test -f 'server/cs.c' -a "${1}" != "-c" ; then
- echo shar: Renaming existing file \"'server/cs.c'\" to \"'server/cs.c.orig'\"
- mv -f 'server/cs.c' 'server/cs.c.orig'
- fi
- echo shar: Extracting \"'server/cs.c'\" \(6810 characters\)
- sed "s/^X//" >'server/cs.c' <<'END_OF_FILE'
- X/*
- X * Galactic Bloodshed, copyright (c) 1989 by Robert P. Chansky,
- X * smq@ucscb.ucsc.edu, mods by people in GB_copyright.h.
- X * Restrictions in GB_copyright.h.
- X * cs.c -- change scope (directory)
- X */
- X
- X#include "GB_copyright.h"
- X#define EXTERN extern
- X#include "vars.h"
- X#include "ships.h"
- X#include "races.h"
- X#include "buffers.h"
- Xint cs_racedata, cs_shdata;
- X
- Xcenter(Playernum, APcount, argn, args)
- Xint Playernum;
- Xint APcount;
- Xint argn;
- Xchar args[MAXARGS][COMMANDSIZE];
- X{
- Xplacetype where;
- X
- X where = Getplace(Playernum,args[1],1);
- X
- X if (where.err) {
- X sprintf(buf,"cs: bad scope.\n");
- X notify(Playernum, buf);
- X return;
- X }
- X
- XDir[Playernum-1].lastx[1] = Stars[where.snum]->xpos;
- XDir[Playernum-1].lasty[1] = Stars[where.snum]->ypos;
- X
- X}
- X
- Xdo_prompt(r)
- Xracetype *r;
- X{
- Xshiptype *s;
- Xint Playernum;
- X
- XPlayernum = r->Playernum;
- X
- X if(Dir[Playernum-1].level==LEVEL_UNIV) {
- X sprintf(Dir[Playernum-1].prompt," ( [%d:%d:%02d] / )\n",
- X r->weekly/60, r->daily/60,
- X Sdata.AP[Playernum-1]);
- X } else if(Dir[Playernum-1].level==LEVEL_STAR) {
- X sprintf(Dir[Playernum-1].prompt," ( [%d:%d:%02d] /%s )\n",
- X r->weekly/60, r->daily/60,
- X Stars[Dir[Playernum-1].snum]->AP[Playernum-1],
- X Stars[Dir[Playernum-1].snum]->name);
- X } else if(Dir[Playernum-1].level==LEVEL_PLAN) {
- X sprintf(Dir[Playernum-1].prompt," ( [%d:%d:%02d] /%s/%s )\n",
- X r->weekly/60, r->daily/60,
- X Stars[Dir[Playernum-1].snum]->AP[Playernum-1],
- X Stars[Dir[Playernum-1].snum]->name,
- X Stars[Dir[Playernum-1].snum]->pnames[Dir[Playernum-1].pnum]);
- X } else if(Dir[Playernum-1].level==LEVEL_SHIP) {
- X openshdata(&cs_shdata);
- X getship(cs_shdata, &s, Dir[Playernum-1].shipno);
- X switch(s->whatorbits) {
- X case LEVEL_UNIV :
- X sprintf(Dir[Playernum-1].prompt," ( [%d:%d:%02d] / #%d)\n",
- X r->weekly/60, r->daily/60, Sdata.AP[Playernum-1],
- X Dir[Playernum-1].shipno);
- X break;
- X case LEVEL_STAR :
- X sprintf(Dir[Playernum-1].prompt," ( [%d:%d:%02d] /%s #%d)\n",
- X r->weekly/60, r->daily/60,
- X Stars[s->storbits]->AP[Playernum-1],
- X Stars[s->storbits]->name,
- X Dir[Playernum-1].shipno);
- X break;
- X case LEVEL_PLAN :
- X sprintf(Dir[Playernum-1].prompt," ( [%d:%d:%02d] /%s/%s #%d)\n",
- X r->weekly/60, r->daily/60,
- X Stars[s->storbits]->AP[Playernum-1],
- X Stars[s->storbits]->name,
- X Stars[s->storbits]->pnames[Dir[Playernum-1].pnum],
- X Dir[Playernum-1].shipno);
- X break;
- X default :
- X break;
- X }
- X close_file(cs_shdata);
- X free(s);
- X }
- X}
- X
- Xcs(Playernum, APcount, argn,args)
- Xint Playernum;
- Xint APcount;
- Xint argn;
- Xchar args[MAXARGS][COMMANDSIZE];
- X{
- X placetype where;
- X planettype *planet;
- X shiptype *s;
- X int cs_shdata,cs_pdata;
- X racetype *Race;
- X
- Xopenracedata(&cs_racedata);
- Xgetrace(cs_racedata, &Race, Playernum);
- Xclose_file(cs_racedata);
- X
- Xif (argn==1) {
- X /* chdir to def scope */
- X Dir[Playernum-1].level = Race->deflevel;
- X if ((Dir[Playernum-1].snum = Race->defsystem) >= Sdata.numstars)
- X Dir[Playernum-1].snum = Sdata.numstars-1;
- X if ((Dir[Playernum-1].pnum = Race->defplanetnum) >= Stars[Dir[Playernum-1].snum]->numplanets)
- X Dir[Playernum-1].pnum = Stars[Dir[Playernum-1].snum]->numplanets-1;
- X Dir[Playernum-1].shipno = 0;
- X Dir[Playernum-1].lastx[0] = Dir[Playernum-1].lasty[0] = 0.0;
- X Dir[Playernum-1].lastx[1] = Stars[Dir[Playernum-1].snum]->xpos;
- X Dir[Playernum-1].lasty[1] = Stars[Dir[Playernum-1].snum]->ypos;
- X free(Race);
- X return;
- X } else if (argn==2) {
- X /* chdir to specified scope */
- X
- X where = Getplace(Playernum,args[1],0); /* do not ignore the fact that you've not
- X explored the place */
- X if (where.err) {
- X sprintf(buf,"cs: bad scope.\n");
- X notify(Playernum, buf);
- X Dir[Playernum-1].lastx[0] = Dir[Playernum-1].lasty[0] = 0.0;
- X free(Race);
- X return;
- X }
- X
- X /* fix lastx, lasty coordinates */
- X
- X switch (Dir[Playernum-1].level) {
- X
- X case LEVEL_UNIV:
- X Dir[Playernum-1].lastx[0] = Dir[Playernum-1].lasty[0] = 0.0;
- X break;
- X
- X case LEVEL_STAR:
- X if (where.level==LEVEL_UNIV) {
- X Dir[Playernum-1].lastx[1] = Stars[Dir[Playernum-1].snum]->xpos;
- X Dir[Playernum-1].lasty[1] = Stars[Dir[Playernum-1].snum]->ypos;
- X } else
- X Dir[Playernum-1].lastx[0] = Dir[Playernum-1].lasty[0] = 0.0;
- X break;
- X
- X case LEVEL_PLAN:
- X openpdata(&cs_pdata);
- X getplanet(cs_pdata,&planet,Stars[Dir[Playernum-1].snum]->planetpos[Dir[Playernum-1].pnum]);
- X close_file(cs_pdata);
- X if (where.level==LEVEL_STAR && where.snum==Dir[Playernum-1].snum) {
- X Dir[Playernum-1].lastx[0] = planet->xpos;
- X Dir[Playernum-1].lasty[0] = planet->ypos;
- X } else if (where.level==LEVEL_UNIV) {
- X Dir[Playernum-1].lastx[1] = Stars[Dir[Playernum-1].snum]->xpos + planet->xpos;
- X Dir[Playernum-1].lasty[1] = Stars[Dir[Playernum-1].snum]->ypos + planet->ypos;
- X } else
- X Dir[Playernum-1].lastx[0] = Dir[Playernum-1].lasty[0] = 0.0;
- X free(planet);
- X break;
- X case LEVEL_SHIP:
- X openshdata(&cs_shdata);
- X getship(cs_shdata, &s, Dir[Playernum-1].shipno);
- X close_file(cs_shdata);
- X if (!s->is_docked) {
- X switch (where.level) {
- X case LEVEL_UNIV:
- X Dir[Playernum-1].lastx[1] = s->xpos;
- X Dir[Playernum-1].lasty[1] = s->ypos;
- X break;
- X case LEVEL_STAR:
- X if (s->whatorbits>=LEVEL_STAR && s->storbits==where.snum) {
- X /* we are going UP from the ship.. change last*/
- X Dir[Playernum-1].lastx[0] = s->xpos - Stars[s->storbits]->xpos;
- X Dir[Playernum-1].lasty[0] = s->ypos - Stars[s->storbits]->ypos;
- X } else
- X Dir[Playernum-1].lastx[0] = Dir[Playernum-1].lasty[0] = 0.0;
- X break;
- X case LEVEL_PLAN:
- X if (s->whatorbits==LEVEL_PLAN && s->storbits==where.snum
- X && s->pnumorbits==where.pnum) {
- X /* same */
- X openpdata(&cs_pdata);
- X getplanet(cs_pdata,&planet,Stars[s->storbits]->planetpos[s->pnumorbits]);
- X close_file(cs_pdata);
- X Dir[Playernum-1].lastx[0] = s->xpos - Stars[s->storbits]->xpos - planet->xpos;
- X Dir[Playernum-1].lasty[0] = s->ypos - Stars[s->storbits]->ypos - planet->ypos;
- X free(planet);
- X } else
- X Dir[Playernum-1].lastx[0] = Dir[Playernum-1].lasty[0] = 0.0;
- X break;
- X case LEVEL_SHIP:
- X Dir[Playernum-1].lastx[0] = Dir[Playernum-1].lasty[0] = 0.0;
- X break;
- X default:
- X break;
- X }
- X } else
- X Dir[Playernum-1].lastx[0] = Dir[Playernum-1].lasty[0] = 0.0;
- X free(s);
- X break;
- X default:
- X break;
- X }
- X
- X Dir[Playernum-1].level = where.level;
- X Dir[Playernum-1].snum = where.snum;
- X Dir[Playernum-1].pnum = where.pnum;
- X Dir[Playernum-1].shipno = where.shipno;
- X
- X
- X } else if (argn==3 && args[1][1]=='d') {
- X /* make new def scope */
- X where = Getplace(Playernum,args[2],0);
- X if (!where.err) {
- X Race->deflevel = where.level;
- X Race->defsystem = where.snum;
- X Race->defplanetnum = where.pnum;
- X openracedata(&cs_racedata);
- X putrace(cs_racedata, Race);
- X close_file(cs_racedata);
- X
- X sprintf(buf,"New home system is %s\n",Dispplace(Playernum, &where));
- X } else {
- X sprintf(buf,"cs: bad home system.\n");
- X free(Race);
- X return;
- X }
- X}
- X free(Race);
- X}
- X
- END_OF_FILE
- if test 6810 -ne `wc -c <'server/cs.c'`; then
- echo shar: \"'server/cs.c'\" unpacked with wrong size!
- fi
- # end of 'server/cs.c'
- if test -f 'server/declare.c' -a "${1}" != "-c" ; then
- echo shar: Renaming existing file \"'server/declare.c'\" to \"'server/declare.c.orig'\"
- mv -f 'server/declare.c' 'server/declare.c.orig'
- fi
- echo shar: Extracting \"'server/declare.c'\" \(8063 characters\)
- sed "s/^X//" >'server/declare.c' <<'END_OF_FILE'
- X/*
- X** Galactic Bloodshed, copyright (c) 1989 by Robert P. Chansky,
- X** smq@ucscb.ucsc.edu, mods by people in GB_copyright.h.
- X** Restrictions in GB_copyright.h.
- X** declare.c -- declare alliance, neutrality, war, the basic thing.
- X*/
- X
- X#include "GB_copyright.h"
- X#define EXTERN extern
- X#include "vars.h"
- X#include "races.h"
- X#include "buffers.h"
- X#include <signal.h>
- X#include <ctype.h>
- Xint declare_racedata, i;
- X
- X/* invite people to join your alliance block */
- Xinvite(Playernum, APcount, argn, args, mode)
- Xint Playernum;
- Xint APcount;
- Xint argn;
- Xchar args[MAXARGS][COMMANDSIZE];
- Xint mode;
- X{
- Xint n;
- Xracetype *Race, *alien;
- X
- XGetPlayer(args[1], &n, &alien);
- X if (n < 1 || n > Numraces() ) {
- X sprintf(buf,"No such player.\n");
- X notify(Playernum, buf);
- X return;
- X }
- X
- Xif(n==Playernum) {
- X notify(Playernum, "Not needed, you are the leader.\n");
- X free(alien);
- X return;
- X }
- X
- X openracedata(&declare_racedata);
- X getrace(declare_racedata, &Race, Playernum);
- X close_file(declare_racedata);
- X
- Xif(mode) {
- X setbit(Blocks[Playernum-1].invite, n);
- X sprintf(buf, "%s [%d] has invited you to join %s\n", Race->name,
- X Playernum, Blocks[Playernum-1].name);
- X if(!notify(n, buf))
- X push_message(TELEG_PLAYER_AUTO, n, buf, TELEGRAM);
- X sprintf(buf, "%s [%d] has been invited to join %s [%d]\n",
- X alien->name, n, Blocks[Playernum-1].name, Playernum);
- X notify(Playernum, buf);
- X } else {
- X clrbit(Blocks[Playernum-1].invite, n);
- X
- X sprintf(buf, "You have been blackballed from %s [%d]\n",
- X Blocks[Playernum-1].name, Playernum);
- X if(!notify(n, buf))
- X push_message(TELEG_PLAYER_AUTO, n, buf, TELEGRAM);
- X
- X sprintf(buf, "%s [%d] has been blackballed from %s [%d]\n",
- X alien->name, n, Blocks[Playernum-1].name, Playernum);
- X notify(Playernum, buf);
- X }
- X for(i=1; i<=Numraces(); i++)
- X push_message(TELEG_PLAYER_AUTO, i, buf, DECLARATION);
- X
- XPutblock(Blocks);
- Xfree(Race);
- Xfree(alien);
- X}
- X
- X/* declare that you wish to be included in the alliance block */
- Xpledge(Playernum, APcount, argn, args, mode)
- Xint Playernum;
- Xint APcount;
- Xint argn;
- Xchar args[MAXARGS][COMMANDSIZE];
- Xint mode;
- X{
- Xint n;
- Xracetype *alien, *Race;
- X
- XGetPlayer(args[1], &n, &alien);
- X if (n < 1 || n > Numraces() ) {
- X sprintf(buf,"No such player.\n");
- X notify(Playernum, buf);
- X return;
- X }
- X
- Xif(n==Playernum) {
- X notify(Playernum, "Not needed, you are the leader.\n");
- X free(alien);
- X return;
- X }
- X
- X openracedata(&declare_racedata);
- X getrace(declare_racedata, &Race, Playernum);
- X close_file(declare_racedata);
- X
- X if(mode) {
- X setbit(Blocks[n-1].pledge, Playernum);
- X sprintf(buf, "%s [%d] has pledged %s.\n", Race->name,
- X Playernum, Blocks[n-1].name);
- X if(!notify(n, buf))
- X push_message(TELEG_PLAYER_AUTO, n, buf, TELEGRAM);
- X sprintf(buf, "You have pledged allegiance to %s.\n",
- X Blocks[n-1].name);
- X notify(Playernum, buf);
- X
- X switch(int_rand(1,20)) {
- X case 1:
- X sprintf(buf, "%s [%d] joins the band wagon and pledges allegiance to %s [%d]!\n",
- X Race->name, Playernum, Blocks[n-1].name, n);
- X break;
- X default:
- X sprintf(buf, "%s [%d] pledges allegiance to %s [%d].\n",
- X Race->name, Playernum, Blocks[n-1].name, n);
- X break;
- X }
- X
- X } else {
- X clrbit(Blocks[n-1].pledge, Playernum);
- X sprintf(buf, "%s [%d] has quit %s [%d].\n", Race->name,
- X Playernum, Blocks[n-1].name, n);
- X if(!notify(n, buf))
- X push_message(TELEG_PLAYER_AUTO, n, buf, TELEGRAM);
- X sprintf(buf, "You have quit %s\n", Blocks[n-1].name);
- X notify(Playernum, buf);
- X
- X switch(int_rand(1,20)) {
- X case 1:
- X sprintf(buf, "%s [%d] calls %s [%d] a bunch of geeks and QUITS %s [%d]!\n",
- X Race->name, Playernum, Blocks[n-1].name, n);
- X default:
- X sprintf(buf, "%s [%d] has QUIT %s [%d]!\n",
- X Race->name, Playernum, Blocks[n-1].name, n);
- X break;
- X }
- X }
- X
- X for(i=1; i<=Numraces(); i++)
- X push_message(TELEG_PLAYER_AUTO, i, buf, DECLARATION);
- X
- X
- Xcompute_power_blocks();
- Xfree(alien);
- Xfree(Race);
- XPutblock(Blocks);
- X}
- X
- Xdeclare(Playernum,APcount, argn,args)
- Xint Playernum;
- Xint APcount;
- Xint argn;
- Xchar args[MAXARGS][COMMANDSIZE];
- X{
- Xchar str[RNAMESIZE];
- Xint n;
- Xracetype *Race, *alien;
- X
- X /* look in sdata for APs first */
- X if (Sdata.AP[Playernum] >= APcount) /* enufAPs would print something */
- X deductAPs(Playernum,APcount, 0, 1);
- X /* otherwise use current star */
- X else if (Dir[Playernum-1].level==LEVEL_STAR || Dir[Playernum-1].level==LEVEL_PLAN) {
- X if (enufAP(Playernum,Stars[Dir[Playernum-1].snum]->AP[Playernum-1], APcount) )
- X deductAPs(Playernum,APcount, Dir[Playernum-1].snum, 0);
- X } else {
- X sprintf(buf,"You don't have enough AP's (%d)\n",APcount);
- X notify(Playernum, buf);
- X return;
- X }
- X
- X GetPlayer(args[1], &n, &alien);
- X if (n < 1 || n > Numraces() ) {
- X sprintf(buf,"No such player.\n");
- X notify(Playernum, buf);
- X return;
- X }
- X
- X openracedata(&declare_racedata);
- X getrace(declare_racedata, &Race, Playernum);
- X close_file(declare_racedata);
- X
- Xif(Race->Playernum != Playernum) {
- X notify(Playernum, "Illegal race number - report to deity.\n");
- X sprintf(buf, "Declare race number error %d != %d\n",
- X Race->Playernum, Playernum);
- X free(Race);
- X free(alien);
- X return;
- X}
- X
- X switch (*args[2]) {
- X case 'a':
- X setbit(Race->allied, n);
- X clrbit(Race->atwar, n);
- X if (int_rand(0,100) >= 96)
- X {
- X sprintf(buf,"But would you want your sister to marry one?\n");
- X notify(Playernum, buf);
- X } else {
- X sprintf(buf,"Good for you.\n");
- X notify(Playernum, buf);
- X }
- X
- X sprintf(buf," Player #%d (%s) has declared an alliance with you!\n",
- X Playernum,Race->name);
- X if(!notify(n, buf))
- X push_message(TELEG_PLAYER_AUTO, n, buf, TELEGRAM);
- X
- X switch(int_rand(1,20)) {
- X case 1:
- X sprintf(buf, "%s [%d] sucks up to %s [%d] and declares an ALLIANCE!\n",
- X Race->name, Playernum, alien->name, n);
- X break;
- X default:
- X sprintf(buf, "%s [%d] declares an ALLIANCE with %s [%d].\n",
- X Race->name, Playernum, alien->name, n);
- X break;
- X }
- X
- X break;
- X case 'n':
- X clrbit(Race->allied, n);
- X clrbit(Race->atwar, n);
- X sprintf(buf,"Done.\n");
- X notify(Playernum, buf);
- X
- X sprintf(buf," Player #%d (%s) has declared neutrality with you!\n",Playernum,Race->name);
- X if(!notify(n, buf))
- X push_message(TELEG_PLAYER_AUTO, n, buf, TELEGRAM);
- X
- X sprintf(buf, "%s [%d] declares a state of neutrality with %s [%d].\n",
- X Race->name, Playernum, alien->name, n);
- X
- X break;
- X case 'w':
- X setbit(Race->atwar, n);
- X clrbit(Race->allied, n);
- X if (int_rand(0,100) >= 96) {
- X sprintf(buf, "Your enemies flaunt their secondary male reproductive glands in your\ngeneral direction.\n");
- X notify(Playernum, buf);
- X } else {
- X sprintf(buf, "Give 'em hell!\n");
- X notify(Playernum, buf);
- X }
- X
- X sprintf(buf," Player #%d (%s) has declared war against you!\n",Playernum,Race->name);
- X if(!notify(n, buf))
- X push_message(TELEG_PLAYER_AUTO, n, buf, TELEGRAM);
- X
- X switch(int_rand(1,5)) {
- X case 1:
- X sprintf(buf, "%s [%d] declares WAR on %s [%d].\n",
- X Race->name, Playernum, alien->name, n);
- X break;
- X case 2:
- X sprintf(buf, "%s [%d] has had enough of %s [%d] and declares WAR!\n",
- X Race->name, Playernum, alien->name, n);
- X break;
- X case 3:
- X sprintf(buf, "%s [%d] decided that it is time to declare WAR on %s [%d]!\n",
- X Race->name, Playernum, alien->name, n);
- X break;
- X case 4:
- X sprintf(buf, "%s [%d] had no choice but to declare WAR against %s [%d]!\n",
- X Race->name, Playernum, alien->name, n);
- X break;
- X case 5:
- X sprintf(buf, "%s [%d] says 'screw it!' and declares WAR on %s [%d]!\n",
- X Race->name, Playernum, alien->name, n);
- X break;
- X default:
- X break;
- X }
- X
- X break;
- X default:
- X notify(Playernum, "I don't understand.\n");
- X free(Race);
- X free(alien);
- X return;
- X break;
- X }
- X
- X for(i=1; i<=Numraces(); i++)
- X push_message(TELEG_PLAYER_AUTO, i, buf, DECLARATION);
- X
- X
- X/* They, of course, learn more about you */
- Xalien->translate[Playernum-1] = MIN(alien->translate[Playernum-1]+30, 100);
- X
- Xopenracedata(&declare_racedata);
- Xputrace(declare_racedata, alien);
- Xputrace(declare_racedata, Race);
- Xclose_file(declare_racedata);
- Xfree(Race);
- Xfree(alien);
- X}
- X
- X
- END_OF_FILE
- if test 8063 -ne `wc -c <'server/declare.c'`; then
- echo shar: \"'server/declare.c'\" unpacked with wrong size!
- fi
- # end of 'server/declare.c'
- if test -f 'server/land.c' -a "${1}" != "-c" ; then
- echo shar: Renaming existing file \"'server/land.c'\" to \"'server/land.c.orig'\"
- mv -f 'server/land.c' 'server/land.c.orig'
- fi
- echo shar: Extracting \"'server/land.c'\" \(6431 characters\)
- sed "s/^X//" >'server/land.c' <<'END_OF_FILE'
- X/*
- X** Galactic Bloodshed, copyright (c) 1989 by Robert P. Chansky,
- X** smq@ucscb.ucsc.edu, mods by people in GB_copyright.h.
- X** Restrictions in GB_copyright.h.
- X**
- X** land.c -- land a ship
- X** also.... dock -- dock a ship w/ another ship
- X** and..... assault -- a very un-PC version of land/dock
- X*/
- X
- X#include "GB_copyright.h"
- X#define EXTERN extern
- X#include "vars.h"
- X#include "ships.h"
- X#include "races.h"
- X#include "buffers.h"
- X#include <signal.h>
- X#include <math.h>
- X
- Xint land_sectdata,land_shdata,land_pdata, land_racedata;
- Xint land_stdata;
- X
- Xland(Playernum,APcount, argn,args)
- Xint Playernum;
- Xint APcount;
- Xint argn;
- Xchar args[MAXARGS][COMMANDSIZE];
- X{
- Xchar c;
- Xshiptype *s;
- Xplanettype *p;
- Xsectortype *sect;
- Xplacetype where;
- Xint shipno,x= -1,y= -1,i, numdest;
- Xfloat fuel;
- Xdouble Dist;
- Xracetype *Race, *alien;
- X
- Xland_sectdata = land_shdata = land_pdata = NEUTRAL_FD;
- X
- X
- X sscanf(args[1]+(args[1][0]=='#'),"%d",&shipno);
- X
- X
- X openshdata(&land_shdata);
- X if (!getship(land_shdata, &s, shipno)) {
- X notify(Playernum, "The ship wasn't found.\n");
- X close_file(land_shdata);
- X return;
- X }
- Xclose_file(land_shdata);
- X
- X if (testship(Playernum,s, shipno)) {
- X notify(Playernum, "Illegal format.\n");
- X free(s);
- X return;
- X }
- X
- X if (s->is_docked) {
- X sprintf(buf,"Ship #%d is docked.\n",shipno);
- X notify(Playernum, buf);
- X free(s);
- X return;
- X }
- X
- X
- X sscanf(args[2],"%d,%d",&x,&y); /* landing on a sector */
- X
- X if (s->whatorbits!=LEVEL_PLAN) {
- X sprintf(buf,"%s #%d doesn't orbit a planet.\n", Shipnames[s->type],
- X shipno);
- X notify(Playernum, buf);
- X free(s);
- X return;
- X }
- X
- X if (!Shipdata[s->type][ABIL_CANLAND]) {
- X sprintf(buf,"This ship is not equipped to land.\n");
- X notify(Playernum, buf);
- X free(s);
- X return;
- X }
- X
- X if(s->storbits != Dir[Playernum-1].snum || s->pnumorbits != Dir[Playernum-1].pnum) {
- X sprintf(buf,"You have to cs to the planet it orbits.\n");
- X notify(Playernum, buf);
- X free(s);
- X return;
- X }
- X
- Xif (!speed_rating(s)) {
- X sprintf(buf,"This ship is not rated for maneuvering.\n");
- X notify(Playernum, buf);
- X free(s);
- X return;
- X }
- X
- X if (!enufAP(Playernum,Stars[s->storbits]->AP[Playernum-1], APcount)) {
- X free(s);
- X return;
- X }
- X
- X openpdata(&land_pdata);
- X getplanet(land_pdata, &p, Stars[s->storbits]->planetpos[s->pnumorbits]);
- X close_file(land_pdata);
- X
- X sprintf(buf,"Planet /%s/%s has gravity field of %.2f.\n", Stars[s->storbits]->name,
- X Stars[s->storbits]->pnames[s->pnumorbits], gravity(p));
- X notify(Playernum, buf);
- X
- X sprintf(buf,"Distance to planet: %.2f.\n",
- X Dist = sqrt((double)Distsq(Stars[s->storbits]->xpos + p->xpos,
- X Stars[s->storbits]->ypos + p->ypos,
- X s->xpos, s->ypos ) ) );
- X notify(Playernum, buf);
- X
- X if (Dist > DIST_TO_LAND) {
- X sprintf(buf,"Ship #%d must be %.3g or closer to the planet (%.2f).\n",shipno, DIST_TO_LAND, Dist);
- X notify(Playernum, buf);
- X free(s);
- X free(p);
- X return;
- X }
- X
- X fuel = 0.05 + .05*s->mass*gravity(p) * LAND_GRAV_MASS_FACTOR;
- X
- X if (s->resource > Max_resource(s) || s->fuel > Max_fuel(s)
- X || s->popn > Max_crew(s) || s->destruct > Max_destruct(s)) {
- X sprintf(buf,"Ship is too overloaded to land.\n");
- X notify(Playernum, buf);
- X free(s);
- X free(p);
- X return;
- X }
- X
- X if(x < 0 || y < 0 || x > p->Maxx || y > p->Maxy) {
- X sprintf(buf,"Illegal coordinates.\n");
- X notify(Playernum, buf);
- X free(s);
- X free(p);
- X return;
- X }
- X
- X opensectdata(&land_sectdata);
- X getsector(land_sectdata,§,p->sectormappos+(y*p->Maxx+x)*sizeof(sectortype));
- X close_file(land_sectdata);
- X
- X if(s->type != OTYPE_TERRA) {
- X openracedata(&land_racedata);
- X getrace(land_racedata, &Race, Playernum);
- X close_file(land_racedata);
- X if (Race->likes[sect->des] == 0.0 && !sect->is_wasted) {
- X sprintf(buf,"The ship is not built to land on that sector.\n");
- X notify(Playernum, buf);
- X free(Race);
- X free(s);
- X free(p);
- X free(sect);
- X return;
- X }
- X }
- X
- X if (sect->is_wasted) {
- X sprintf(buf,"Warning: That sector is a wasteland!\n");
- X notify(Playernum, buf);
- X } else if (sect->owner && sect->owner!=Playernum) {
- X openracedata(&land_racedata);
- X getrace(land_racedata, &Race, Playernum);
- X getrace(land_racedata, &alien, (int)sect->owner);
- X close_file(land_racedata);
- X
- X if(!(isset(Race->allied, sect->owner) && isset(alien->allied, Playernum))) {
- X sprintf(buf,"You are not mutually allied with %s.\n", alien->name);
- X notify(Playernum, buf);
- X free(Race);
- X free(alien);
- X free(sect);
- X free(p);
- X free(s);
- X return;
- X } else {
- X sprintf(buf,"You have landed on allied sector (%s).\n",alien->name);
- X notify(Playernum, buf);
- X }
- X free(alien);
- X free(Race);
- X }
- X
- X if (s->fuel < fuel) {
- X
- X kill_ship(s->owner, s);
- X
- X where.level = LEVEL_PLAN;
- X where.snum = s->storbits;
- X where.pnum = s->pnumorbits;
- X
- X numdest =(int)blast(Playernum,&where, &where, 0, p, x, y, Dist, 100.,
- X round_rand(log1p((double)s->mass)*2+(float)s->destruct/3.), 1);
- X sprintf(buf,"BOOM!! Ship #%d crashes on sector %d,%d with blast radius of %d.\n",
- X shipno, x, y, numdest);
- X
- X for (i=1; i<=Numraces(); i++)
- X if (p->info[i-1].numsectsowned || i==Playernum)
- X notify(i, buf);
- X
- X } else {
- X s->xpos = (float)x;
- X s->ypos = (float)y;
- X
- X s->fuel -= fuel;
- X s->mass -= fuel * MASS_FUEL;
- X s->is_docked = 1;
- X s->whatdest = LEVEL_PLAN; /* no destination */
- X s->deststar = s->storbits;
- X s->destpnum = s->pnumorbits;
- X }
- X
- X openshdata(&land_shdata);
- X putship(land_shdata, s, shipno);
- X close_file(land_shdata);
- X
- X
- X if (s->whatorbits==LEVEL_UNIV)
- X deductAPs(Playernum,APcount, 0, 1);
- X else
- X deductAPs(Playernum,APcount, s->storbits, 0);
- X
- X
- X openpdata(&land_pdata);
- X putplanet(land_pdata,p,Stars[s->storbits]->planetpos[s->pnumorbits]);
- X close_file(land_pdata);
- X
- X if(numdest) {
- X opensectdata(&land_sectdata);
- X putsector(land_sectdata,sect,p->sectormappos+(y*p->Maxx+x)*sizeof(sectortype));
- X close_file(land_sectdata);
- X }
- X
- X /* send messages to anyone there */
- X sprintf(buf,"%s #%d observed landing on sector %.0f,%.0f, planet /%s/%s.\n",
- X Shipnames[s->type], shipno, s->xpos,s->ypos,Stars[s->storbits]->name,
- X Stars[s->storbits]->pnames[s->pnumorbits]);
- X
- X for (i=1; i<=Numraces(); i++)
- X if (p->info[i-1].numsectsowned && i!=Playernum)
- X notify(i, buf);
- X
- X sprintf(buf,"%s #%d %s landed on planet.\n",Shipnames[s->type],
- X shipno,s->name);
- X notify(Playernum, buf);
- X
- X free(sect);
- X free(p);
- X free(s);
- X
- X}
- X
- X
- END_OF_FILE
- if test 6431 -ne `wc -c <'server/land.c'`; then
- echo shar: \"'server/land.c'\" unpacked with wrong size!
- fi
- # end of 'server/land.c'
- if test -f 'server/launch.c' -a "${1}" != "-c" ; then
- echo shar: Renaming existing file \"'server/launch.c'\" to \"'server/launch.c.orig'\"
- mv -f 'server/launch.c' 'server/launch.c.orig'
- fi
- echo shar: Extracting \"'server/launch.c'\" \(6685 characters\)
- sed "s/^X//" >'server/launch.c' <<'END_OF_FILE'
- X/*
- X * Galactic Bloodshed, copyright (c) 1989 by Robert P. Chansky,
- X * smq@ucscb.ucsc.edu, mods by people in GB_copyright.h.
- X * Restrictions in GB_copyright.h.
- X *
- X * launch.c -- launch or undock a ship (also undock)
- X */
- X
- X#include "GB_copyright.h"
- X#define EXTERN extern
- X#include "vars.h"
- X#include "ships.h"
- X#include "buffers.h"
- X#include <signal.h>
- X
- X
- Xint launch_shdata,launch_pdata,launch_stdata;
- X
- Xlaunch(Playernum,APcount, argn,args)
- Xint Playernum;
- Xint APcount;
- Xint argn;
- Xchar args[MAXARGS][COMMANDSIZE];
- X{
- Xint sh, sh2, sh3;
- Xshiptype *s,*s2,*s3;
- Xplanettype *p;
- Xboolean planet=0;
- Xint shipno, i;
- Xfloat fuel;
- X
- Xlaunch_shdata = launch_pdata = NEUTRAL_FD;
- X
- X sscanf(args[1]+(args[1][0]=='#'),"%d",&shipno);
- X
- X openshdata(&launch_shdata);
- X if (!getship(launch_shdata, &s, shipno)) {
- X close_file(launch_shdata);
- X return;
- X }
- Xclose_file(launch_shdata);
- X
- X
- X if (s->owner!=Playernum) {
- X DontOwnErr(Playernum,shipno);
- X free(s);
- X return;
- X }
- X
- X if (!speed_rating(s)) {
- X sprintf(buf,"That ship is not designed to be launched.\n");
- X notify(Playernum, buf);
- X free(s);
- X return;
- X }
- X
- X
- X if (testship(Playernum,s,shipno)) {
- X free(s);
- X return;
- X }
- X
- X if (!s->is_docked) {
- X sprintf(buf,"Ship #%d is not landed or docked.\n",shipno);
- X notify(Playernum, buf);
- X free(s);
- X return;
- X }
- X
- X if (s->whatdest==LEVEL_PLAN && s->resource > Max_resource(s)) {
- X sprintf(buf,"Ship #%d is too overloaded to launch.\n", shipno);
- X notify(Playernum, buf);
- X free(s);
- X return;
- X }
- X
- X if (s->whatdest==LEVEL_SHIP) {
- X
- X sh2 = s->destshipno;
- X
- X openshdata(&launch_shdata);
- X (void)getship(launch_shdata, &s2, sh2);
- X close_file(launch_shdata);
- X if (s2->whatorbits==LEVEL_UNIV) {
- X if (!enufAP(Playernum,Sdata.AP[Playernum-1], APcount)) {
- X free(s);
- X free(s2);
- X return;
- X } else
- X deductAPs(Playernum,APcount, 0, 1);
- X } else {
- X if (!enufAP(Playernum,Stars[s->storbits]->AP[Playernum-1], APcount)) {
- X free(s);
- X free(s2);
- X return;
- X } else
- X deductAPs(Playernum,APcount, s->storbits, 0);
- X }
- X
- X if(s->type == STYPE_FIGHTER && s2->type == STYPE_CARRIER &&
- X s2->destshipno!=shipno) {
- X
- X /* fighters docked with carriers - in the sublist!*/
- X /* fix carrier linked list */
- X
- X sh = s2->object.number;
- X if(!sh) {
- X notify(Playernum, "Weird error! 01\n");
- X free(s);
- X free(s2);
- X return;
- X }
- X
- X if(sh == shipno) {
- X s2->object.number = s->object.number;
- X } else {
- X
- X openshdata(&launch_shdata);
- X while(sh != shipno) {
- X (void)getship(launch_shdata, &s3, sh);
- X sh3 = sh;
- X sh = s3->object.number;
- X if(sh != shipno) free(s3);
- X }
- X
- X s3->object.number = s->object.number; /* change pointer */
- X putship(launch_shdata, s3, sh3);
- X close_file(launch_shdata);
- X free(s3);
- X }
- X
- X /* fighter is on its own */
- X s->is_docked = 0;
- X s->whatdest = LEVEL_UNIV;
- X s->whatorbits = s2->whatorbits;
- X s->object.number = 0;
- X s->object.number4 = 0;
- X s->destshipno = 0;
- X s->xpos = s2->xpos;
- X s->ypos = s2->ypos;
- X s->storbits = s2->storbits;
- X s->pnumorbits = s2->pnumorbits;
- X
- X s2->mass -= s->mass; /* carrier is lighter */
- X s2->object.number4 -= 1;
- X/* put fighter into the appropriate linked list (planet/star/universe).
- X it is put into the level of the carrier */
- X
- X if(s2->whatorbits==LEVEL_PLAN) {
- X openpdata(&launch_pdata);
- X getplanet(launch_pdata, &p, Stars[s2->storbits]->planetpos[s2->pnumorbits]);
- X s->nextship = p->ships;
- X p->ships = shipno;
- X putplanet(launch_pdata,p,Stars[s2->storbits]->planetpos[s2->pnumorbits]);
- X close_file(launch_pdata);
- X free(p);
- X } else if(s2->whatorbits==LEVEL_STAR) {
- X openstardata(&launch_stdata);
- X free(Stars[s2->storbits]);
- X getstar(launch_stdata, &Stars[s2->storbits],s2->storbits);
- X s->nextship = Stars[s2->storbits]->ships;
- X Stars[s2->storbits]->ships = shipno;
- X putstar(launch_stdata, Stars[s2->storbits],s2->storbits);
- X close_file(launch_stdata);
- X } else if(s2->whatorbits==LEVEL_UNIV) {
- X s->nextship = Sdata.ships;
- X Sdata.ships = shipno;
- X }
- X
- X } else {
- X s->is_docked = 0;
- X s->whatdest = LEVEL_UNIV;
- X sh2 = s->destshipno;
- X s->destshipno = 0;
- X s2->is_docked = 0;
- X s2->whatdest = LEVEL_UNIV;
- X s2->destshipno = 0;
- X
- X }
- X
- X
- X sprintf(buf,"%s #%d undocked from %s #%d.\n",
- X Shipnames[s->type], shipno, Shipnames[s2->type],sh2);
- X notify(Playernum, buf);
- X openshdata(&launch_shdata);
- X putship(launch_shdata, s, shipno);
- X putship(launch_shdata, s2, sh2);
- X close_file(launch_shdata);
- X
- X free(s);
- X free(s2);
- X
- X } else {
- X
- X if (!enufAP(Playernum,Stars[s->storbits]->AP[Playernum-1], APcount)) {
- X free(s);
- X return;
- X } else
- X deductAPs(Playernum,APcount, s->storbits, 0);
- X
- X s->is_docked = 0;
- X s->whatdest = LEVEL_UNIV; /* no destination */
- X
- X
- X /* adjust x,ypos to absolute coords */
- X openpdata(&launch_pdata);
- X getplanet(launch_pdata, &p, Stars[s->storbits]->planetpos[s->pnumorbits]);
- X close_file(launch_pdata);
- X
- X sprintf(buf,"Planet /%s/%s has gravity field of %.2f\n", Stars[s->storbits]->name,
- X Stars[s->storbits]->pnames[s->pnumorbits], gravity(p));
- X notify(Playernum, buf);
- X /* alter sector location of ship x,y to stellar coords x,y */
- X s->xpos = Stars[s->storbits]->xpos + p->xpos +
- X (float)int_rand((int)(-DIST_TO_LAND/4),(int)(DIST_TO_LAND/4));
- X s->ypos = Stars[s->storbits]->ypos + p->ypos +
- X (float)int_rand((int)(-DIST_TO_LAND/4),(int)(DIST_TO_LAND/4));
- X
- X /* subtract fuel from ship */
- X fuel = gravity(p) * s->mass * LAUNCH_GRAV_MASS_FACTOR;
- X if (s->fuel < fuel) {
- X sprintf(buf,"Ship #%d does not have enough fuel! (%.1f)\n",shipno, fuel);
- X notify(Playernum, buf);
- X free(p);
- X free(s);
- X return;
- X }
- X s->fuel -= fuel;
- X s->mass -= fuel * MASS_FUEL;
- X
- X
- X if (s->type == OTYPE_CANIST)
- X s->object.number = 80; /* canister dissapates after 80 updates */
- X
- X s->notified = 0;
- X openshdata(&launch_shdata);
- X putship(launch_shdata, s, shipno);
- X close_file(launch_shdata);
- X
- X if (!p->is_explored) {
- X /* not yet explored by owner; space exploration causes the
- X player to see a whole map */
- X p->is_explored = 1;
- Xopenpdata(&launch_pdata);
- X putplanet(launch_pdata,p,Stars[s->storbits]->planetpos[s->pnumorbits]);
- X close_file(launch_pdata);
- X }
- X
- X sprintf(buf,"%s #%d observed launching from planet /%s/%s.\n",
- X Shipnames[s->type], shipno,Stars[s->storbits]->name,
- X Stars[s->storbits]->pnames[s->pnumorbits]);
- X for (i=1; i<=Numraces(); i++)
- X if (p->info[i-1].numsectsowned && i!=Playernum) notify(i, telegram_buf);
- X
- X free(p);
- X
- X sprintf(buf,"%s #%d %s launched from planet,", Shipnames[s->type], shipno, s->name);
- X notify(Playernum, buf);
- X sprintf(buf," using %.1f fuel.\n",fuel);
- X notify(Playernum, buf);
- X if (s->type == OTYPE_CANIST) {
- X notify(Playernum, buf);
- X sprintf(buf, "A thick cloud of dust envelops your planet.\n");
- X notify(Playernum, buf);
- X }
- X
- X free(s);
- X
- X }
- X
- X}
- X
- X
- END_OF_FILE
- if test 6685 -ne `wc -c <'server/launch.c'`; then
- echo shar: \"'server/launch.c'\" unpacked with wrong size!
- fi
- # end of 'server/launch.c'
- if test -f 'server/scrap.c' -a "${1}" != "-c" ; then
- echo shar: Renaming existing file \"'server/scrap.c'\" to \"'server/scrap.c.orig'\"
- mv -f 'server/scrap.c' 'server/scrap.c.orig'
- fi
- echo shar: Extracting \"'server/scrap.c'\" \(7618 characters\)
- sed "s/^X//" >'server/scrap.c' <<'END_OF_FILE'
- X/*
- X * Galactic Bloodshed, copyright (c) 1989 by Robert P. Chansky,
- X * smq@ucscb.ucsc.edu, mods by people in GB_copyright.h.
- X * Restrictions in GB_copyright.h.
- X *
- X * scrap.c -- turn a ship to junk
- X */
- X
- X#include "GB_copyright.h"
- X#define EXTERN extern
- X#include "vars.h"
- X#include "ships.h"
- X#include "races.h"
- X#include "buffers.h"
- X#include <signal.h>
- X
- Xint scrap_shdata, scrap_pdata,scrap_sectdata, scrap_racedata;
- X
- Xscrap(Playernum,APcount, argn,args)
- Xint Playernum;
- Xint APcount;
- Xint argn;
- Xchar args[MAXARGS][COMMANDSIZE];
- X{
- Xplanettype *planet;
- Xsectortype *sect;
- Xshiptype *s,*s2;
- Xint i,mask,shipno,scrapval=0,destval=0,crewval=0, xtalval=0;
- Xfloat fuelval=0.0;
- Xracetype *Race;
- X
- Xscrap_shdata = scrap_pdata = NEUTRAL_FD;
- X
- X sscanf(args[1] + (*args[1]=='#'),"%d", &shipno);
- X
- X openshdata(&scrap_shdata);
- X if (!getship(scrap_shdata,&s,shipno)) {
- X close_file(scrap_shdata);
- X return;
- X }
- Xclose_file(scrap_shdata);
- X
- X if (s->owner!=Playernum || !s->is_alive) {
- X DontOwnErr(Playernum,shipno);
- X free(s);
- X return;
- X }
- X
- X
- X if (s->whatorbits==LEVEL_UNIV) {
- X if (!enufAP(Playernum,Sdata.AP[Playernum-1], APcount))
- X free(s);
- X return;
- X } else if (!enufAP(Playernum,Stars[s->storbits]->AP[Playernum-1], APcount)) {
- X free(s);
- X return;
- X }
- X
- X if (s->whatorbits==LEVEL_PLAN && s->type==OTYPE_TOXWC) {
- X sprintf(buf,"WARNING: This will release %d toxin points back into the atmosphere!!\n", s->object.number);
- X notify(Playernum, buf);
- X }
- X
- X if ( !s->is_docked) {
- X sprintf(buf,"%s #%d is not landed or docked.\nNo resources can be reclaimed.\n",Shipnames[s->type], shipno);
- X notify(Playernum, buf);
- X }
- X
- X if (s->whatorbits==LEVEL_PLAN) { /* wc's release poison */
- X openpdata(&scrap_pdata);
- X getplanet(scrap_pdata, &planet, Stars[s->storbits]->planetpos[s->pnumorbits]);
- X close_file(scrap_pdata);
- X
- X if (s->is_docked && s->whatdest==LEVEL_PLAN) {
- X opensectdata(&scrap_sectdata);
- X getsector(scrap_sectdata, §, planet->sectormappos
- X +((int)s->ypos*planet->Maxx+(int)s->xpos)*sizeof(sectortype));
- X close_file(scrap_sectdata);
- X }
- X
- X }
- X
- X
- X if (s->is_docked && s->whatdest==LEVEL_SHIP) {
- X openshdata(&scrap_shdata);
- X if (!getship(scrap_shdata, &s2, (int)s->destshipno)) {
- X close_file(scrap_shdata);
- X free(s);
- X return;
- X }
- X close_file(scrap_shdata);
- X if ( !(s2->is_docked && s2->destshipno == shipno) ) {
- X sprintf(buf,"Warning, other ship not docked..\n");
- X notify(Playernum, buf);
- X free(s);
- X free(s2);
- X return;
- X }
- X }
- X
- X scrapval = Cost(s) * .50 + s->resource;
- X
- X if (s->is_docked) {
- X
- X sprintf(buf,"%s #%d:original cost: %d\n",
- X Shipnames[s->type], shipno, Cost(s));
- X notify(Playernum, buf);
- X sprintf(buf," scrap value%s: %d rp's.\n",
- X s->resource ? "(with stockpile) " : "", scrapval);
- X notify(Playernum, buf);
- X
- X if (s->whatdest==LEVEL_SHIP && s->resource+scrapval > Max_resource(s2)
- X && s->type!=STYPE_SHUTTLE) {
- X scrapval = Max_resource(s2) - s->resource;
- X sprintf(buf,"(There is only room for %d resources.)\n",scrapval);
- X notify(Playernum, buf);
- X }
- X
- X if (s->fuel) {
- X sprintf(buf,"Fuel recovery: %.0f.\n", s->fuel);
- X notify(Playernum, buf);
- X fuelval = s->fuel;
- X if (s->whatdest == LEVEL_SHIP && s->fuel+fuelval > Max_fuel(s2)) {
- X fuelval = Max_fuel(s2) - s->fuel;
- X sprintf(buf,"(There is only room for %.2f fuel.)\n",fuelval);
- X notify(Playernum, buf);
- X }
- X } else
- X fuelval = 0.0;
- X
- X if (s->destruct) {
- X sprintf(buf,"Weapons recovery: %d.\n", s->destruct);
- X notify(Playernum, buf);
- X destval = s->destruct;
- X if (s->whatdest == LEVEL_SHIP && s->destruct+destval > Max_destruct(s2)) {
- X destval = Max_destruct(s2) - s->destruct;
- X sprintf(buf,"(There is only room for %d destruct.)\n",destval);
- X notify(Playernum, buf);
- X }
- X } else
- X destval = 0;
- X
- X if (s->popn) {
- X if (s->whatdest==LEVEL_PLAN && sect->owner>0 && sect->owner!=Playernum) {
- X sprintf(buf,"You don't own this sector; no crew can be recovered.\n");
- X notify(Playernum, buf);
- X } else {
- X sprintf(buf,"Population recovery: %d.\n", s->popn);
- X notify(Playernum, buf);
- X crewval = s->popn;
- X if (s->whatdest==LEVEL_SHIP && s->popn+crewval > Max_crew(s2)) {
- X crewval = Max_crew(s) - s->popn;
- X sprintf(buf,"(There is only room for %d crew.)\n",crewval);
- X notify(Playernum, buf);
- X }
- X }
- X } else
- X crewval = 0;
- X
- X if (s->crystals) {
- X if (s->whatdest==LEVEL_PLAN && sect->owner>0 && sect->owner!=Playernum) {
- X sprintf(buf,"You don't own this sector; no crystals can be recovered.\n");
- X notify(Playernum, buf);
- X } else {
- X sprintf(buf,"Crystal recovery: %d.\n", s->crystals);
- X notify(Playernum, buf);
- X xtalval = s->crystals;
- X if (s->whatdest==LEVEL_SHIP && s->crystals+xtalval > Max_crystals(s2)) {
- X xtalval = Max_crystals(s) - s->crystals;
- X sprintf(buf,"(There is only room for %d crystals.)\n",xtalval);
- X notify(Playernum, buf);
- X }
- X }
- X } else
- X xtalval = 0;
- X
- X}
- X
- X
- X
- X if (s->whatorbits==LEVEL_UNIV)
- X deductAPs(Playernum,APcount, 0, 1);
- X else
- X deductAPs(Playernum,APcount, s->storbits, 0);
- X
- X kill_ship(Playernum, s);
- X
- Xopenshdata(&scrap_shdata);
- Xputship(scrap_shdata, s, shipno);
- Xclose_file(scrap_shdata);
- X if (s->is_docked && s->whatdest==LEVEL_SHIP) {
- X fuelval = MIN(fuelval, 1.*Max_fuel(s2) - s2->fuel);
- X destval = MIN(destval, Max_destruct(s2) - s2->destruct);
- X scrapval = MIN(scrapval, Max_resource(s2) - s2->resource);
- X crewval = MIN(crewval, Max_crew(s2) - s2->popn);
- X xtalval = MIN(xtalval, Max_crystals(s2) - s2->crystals);
- X s2->fuel += fuelval;
- X s2->destruct += destval;
- X s2->resource += scrapval;
- X s2->popn += crewval;
- X s2->crystals += xtalval;
- X
- Xopenracedata(&scrap_racedata);
- Xgetrace(scrap_racedata, &Race, Playernum);
- Xclose_file(scrap_racedata);
- X s2->mass += fuelval*MASS_FUEL + destval*MASS_DESTRUCT + scrapval*MASS_RESOURCE + crewval*Race->mass;
- Xfree(Race);
- X
- X s2->is_docked = 0; /* undock the surviving ship */
- X s2->whatdest = LEVEL_UNIV;
- X s2->destshipno = 0;
- X openshdata(&scrap_shdata);
- X putship(scrap_shdata, s2, s->destshipno);
- X close_file(scrap_shdata);
- X free(s2);
- X }
- X
- X
- X
- X if (s->whatorbits==LEVEL_PLAN) {
- X
- X /* distribute poison over planet even if orbiting */
- X if (s->type==OTYPE_TOXWC) {
- X if (planet->conditions[TOXIC] > 100 - s->object.number)
- X planet->conditions[TOXIC] = 100;
- X else
- X planet->conditions[TOXIC] += s->object.number;
- X
- X sprintf(buf,"Planetary toxin concentration is now %d.\n",
- X planet->conditions[TOXIC]);
- X notify(Playernum, buf);
- X }
- X
- X if (s->is_docked && s->whatdest==LEVEL_PLAN) {
- X
- X if (sect->owner==Playernum) {
- X sect->popn += crewval;
- X } else if (sect->owner == 0) {
- X sect->owner = Playernum;
- X sect->popn += crewval;
- X planet->info[Playernum-1].numsectsowned++;
- X sprintf(buf,"Sector %.0f,%.0f Colonized.\n",s->xpos,s->ypos);
- X notify(Playernum, buf);
- X }
- X planet->info[Playernum-1].resource += scrapval;
- X planet->popn += crewval;
- X planet->info[Playernum-1].destruct += destval;
- X planet->info[Playernum-1].fuel += (int)fuelval;
- X planet->info[Playernum-1].crystals += (int)xtalval;
- X
- X opensectdata(&scrap_sectdata);
- X putsector(scrap_sectdata, sect, planet->sectormappos
- X +((int)s->ypos*planet->Maxx+(int)s->xpos)*sizeof(sectortype));
- X close_file(scrap_sectdata);
- X free(sect);
- X
- X }
- X
- X openpdata(&scrap_pdata);
- X putplanet(scrap_pdata, planet, Stars[s->storbits]->planetpos[s->pnumorbits]);
- X close_file(scrap_pdata);
- X free(planet);
- X }
- X
- X
- X if (s->is_docked && s->whatdest==LEVEL_PLAN) {
- X sprintf(buf,"\nScrapped.\n");
- X notify(Playernum, buf);
- X } else {
- X sprintf(buf,"\nDestroyed.\n");
- X notify(Playernum, buf);
- X }
- X
- X free(s);
- X}
- X
- X
- END_OF_FILE
- if test 7618 -ne `wc -c <'server/scrap.c'`; then
- echo shar: \"'server/scrap.c'\" unpacked with wrong size!
- fi
- # end of 'server/scrap.c'
- if test -f 'server/ships.h' -a "${1}" != "-c" ; then
- echo shar: Renaming existing file \"'server/ships.h'\" to \"'server/ships.h.orig'\"
- mv -f 'server/ships.h' 'server/ships.h.orig'
- fi
- echo shar: Extracting \"'server/ships.h'\" \(7935 characters\)
- sed "s/^X//" >'server/ships.h' <<'END_OF_FILE'
- X/*
- X * Galactic Bloodshed, copyright (c) 1989 by Robert P. Chansky,
- X * smq@ucscb.ucsc.edu, mods by people in GB.c, enroll.dat.
- X * Restrictions in GB.c.
- X */
- X
- X
- X#define STYPE_POD 0
- X#define STYPE_SHUTTLE 1
- X#define STYPE_CARRIER 2
- X#define STYPE_DREADNT 3
- X#define STYPE_BATTLE 4
- X#define STYPE_INTCPT 5
- X#define STYPE_CRUISER 6
- X#define STYPE_DESTROYER 7
- X#define STYPE_FIGHTER 8
- X#define STYPE_EXPLORER 9
- X#define STYPE_HABITAT 10
- X#define STYPE_STATION 11
- X#define STYPE_ASS 12
- X#define STYPE_CARGO 13
- X#define STYPE_TANKER 14
- X#define STYPE_GOD 15
- X#define STYPE_MINE 16
- X#define STYPE_MIRROR 17
- X
- X#define OTYPE_STELE 18
- X#define OTYPE_GTELE 19
- X#define OTYPE_TRACT 20
- X#define OTYPE_AP 21
- X#define OTYPE_CANIST 22
- X#define OTYPE_VN 23
- X#define OTYPE_BERS 24
- X#define OTYPE_GOV 25
- X#define OTYPE_OMCL 26
- X#define OTYPE_TOXWC 27
- X#define OTYPE_PROBE 28
- X#define OTYPE_GR 29
- X#define OTYPE_FACTORY 30
- X#define OTYPE_TERRA 31
- X#define OTYPE_BERSCTLC 32
- X#define OTYPE_AUTOFAC 33
- X#define OTYPE_TRANSDEV 34
- X#define OTYPE_REPAIR 35
- X#define OTYPE_PLANDEF 36
- X
- X#define ABIL_CARGO 0
- X#define ABIL_DESTCAP 1
- X#define ABIL_GUNS 2
- X#define ABIL_FUELCAP 3
- X#define ABIL_TECH 4
- X#define ABIL_MAXCREW 5
- X#define ABIL_ARMOR 6
- X#define ABIL_COST 7
- X#define ABIL_JUMP 8
- X#define ABIL_CANLAND 9
- X#define ABIL_HASSWITCH 10
- X#define ABIL_SPEED 11
- X#define ABIL_DAMAGE 12
- X#define ABIL_BUILD 13
- X#define ABIL_CONSTRUCT 14
- X#define ABIL_MOD 15
- X#define ABIL_LASER 16
- X#define ABIL_PROGRAMMED 17
- X
- X#define NUMSTYPES (OTYPE_PLANDEF+1)
- X#define NUMABILS (ABIL_PROGRAMMED+1)
- X
- X#define SHIP_NAMESIZE 18
- X
- X
- X
- Xtypedef struct ship shiptype;
- Xtypedef struct ship_new shiptype_new;
- Xtypedef struct place placetype;
- X
- X
- Xstruct ship {
- X float xpos,ypos;
- X float fuel,mass;
- X char name[SHIP_NAMESIZE]; /* name of ship (optional) */
- X char class[SHIP_NAMESIZE]; /* class of ship - designated by players */
- X char mission[64]; /* notes for each ship */
- X percent morale; /* morale of the crew */
- X unsigned short command; /* captain+staff leadership value */
- X
- X int dummy1;
- X
- X unsigned short destshipno; /* destination ship # */
- X unsigned short nextship; /* next ship in linked list */
- X
- X percent armor;
- X percent guns;
- X percent size;
- X
- X unsigned short max_crew;
- X unsigned short max_resource;
- X unsigned short max_destruct;
- X unsigned short max_fuel;
- X unsigned short max_speed;
- X unsigned short build_type; /* for factories - type of ship it makes */
- X unsigned short build_cost;
- X
- X int dummy2;
- X
- X float base_mass;
- X float tech; /* technology rating */
- X
- X unsigned short destruct; /* stuff it's carrying */
- X unsigned short resource;
- X unsigned short popn; /* crew */
- X unsigned short crystals;
- X
- X
- X struct a { /* if the ship is a Space Mirror */
- X unsigned short shipno; /* aimed at what ship */
- X char snum; /* aimed at what star */
- X percent intensity; /* intensity of aiming */
- X unsigned pnum : BITS_MAXPLANETS; /* aimed at what planet */
- X unsigned level : 2; /* aimed at what level */
- X } aimed_at;
- X
- X struct o2 {
- X short number; /* for misc functions */
- X short number2; /* again */
- X short number3;
- X short number4; /* again */
- X } object;
- X
- X struct nv {
- X unsigned on : 1; /* toggles navigate mode */
- X unsigned speed : 4; /* speed for navigate command */
- X unsigned turns : 15;/* number turns left in maneuver */
- X unsigned bearing : 9; /* course */
- X unsigned dummy : 3;
- X } navigate;
- X
- X struct prot {
- X float maxrng; /* maximum range for autoshoot */
- X unsigned on : 1; /* toggle on/off */
- X unsigned planet : 1; /* planet defender */
- X unsigned self : 1; /* retaliate if attacked */
- X unsigned evade : 1; /* evasive action */
- X unsigned ship : 14; /* ship it is protecting */
- X unsigned dummy : 6;
- X } protect;
- X
- X struct hd {
- X unsigned int charge : 7;
- X unsigned ready : 1;
- X unsigned on : 1;
- X unsigned has : 1;
- X unsigned mounted : 1; /* has crystal mounted */
- X unsigned dummy : 5;
- X } hyper_drive;
- X
- X
- X unsigned owner : BITS_MAXPLAYERS; /* owner of ship */
- X char storbits; /* what star # orbits */
- X char deststar; /* destination star */
- X unsigned destpnum : BITS_MAXPLANETS; /* destination planet */
- X unsigned pnumorbits : BITS_MAXPLANETS; /* # of planet if orbiting */
- X unsigned whatdest : 2; /* where going (same as Dir) */
- X unsigned whatorbits : 2; /* where orbited (same as Dir) */
- X
- X unsigned damage : 7; /* amt of damage */
- X unsigned rad : 7; /* radiation level */
- X unsigned short retaliate;
- X unsigned short laser;
- X
- X unsigned type : 6; /* what type ship is */
- X unsigned active: 1; /* tells whether the ship is active */
- X unsigned is_alive : 1; /* 1 bit: ship is alive */
- X unsigned mode : 1;
- X unsigned bombard : 1; /* bombard planet we're orbiting */
- X
- X unsigned speed : 4; /* what speed to travel at 0-9 */
- X unsigned is_cloaked : 1; /* 1 bit: is cloaked ship */
- X unsigned is_sheep : 1; /* 1 bit: is under influence of mind control */
- X unsigned is_docked : 1; /* 1 bit: is landed on a planet or docked */
- X unsigned notified : 1; /* 1bit: has been notified of something */
- X unsigned is_examined : 1; /* 1 bit: has been examined */
- X unsigned on : 1; /* on or off */
- X unsigned short fire_laser; /* retaliation strength for lasers */
- X unsigned dummy4 : 1;
- X};
- X
- X
- Xstruct place { /* used in function return for finding place */
- X char snum;
- X char pnum;
- X short shipno;
- X shiptype *shipptr;
- X unsigned level : 2; /* .level: same as Dir */
- X unsigned err : 1; /* if error */
- X unsigned dummy : 13;
- X};
- X
- X /* whether ship is an object or not */
- X#define is_object(s) ((s)->type > STYPE_MIRROR)
- X
- X /* can takeoff & land, is mobile, etc. */
- X#define speed_rating(s) ((s)->max_speed)
- X
- X /* has an on/off switch */
- X#define has_switch(s) (Shipdata[(s)->type][ABIL_HASSWITCH])
- X
- X /* can bombard planets */
- X#define can_bombard(s) \
- X (Shipdata[(s)->type][ABIL_GUNS] && ((s)->type != STYPE_MINE))
- X
- X/* can navigate */
- X#define can_navigate(s) (Shipdata[(s)->type][ABIL_SPEED] > 0 && (s)->type != OTYPE_TERRA && (s)->type != OTYPE_VN)
- X
- X /* can aim at things. */
- X#define can_aim(s) ((s)->type>=STYPE_MIRROR && (s)->type<=OTYPE_TRACT)
- X
- X /* macro for killing a ship. !notified means we have not yet written it
- X to the dead_ship file. */
- X/* macros to get ship stats */
- X#define Armor(s) ( ((s)->type==OTYPE_FACTORY) ? Shipdata[(s)->type][ABIL_ARMOR] : (s)->armor)
- X#define Guns(s) ( ((s)->type==OTYPE_FACTORY) ? Shipdata[(s)->type][ABIL_GUNS] : (s)->guns)
- X#define Laser(s) ( ((s)->type==OTYPE_FACTORY) ? Shipdata[(s)->type][ABIL_LASER] : (s)->laser)
- X#define Max_crew(s) ( ((s)->type==OTYPE_FACTORY) ? Shipdata[(s)->type][ABIL_MAXCREW] : (s)->max_crew)
- X#define Max_resource(s) ( ((s)->type==OTYPE_FACTORY) ? Shipdata[(s)->type][ABIL_CARGO] : (s)->max_resource)
- X#define Max_fuel(s) ( ((s)->type==OTYPE_FACTORY) ? Shipdata[(s)->type][ABIL_FUELCAP] : (s)->max_fuel)
- X#define Max_destruct(s) ( ((s)->type==OTYPE_FACTORY) ? Shipdata[(s)->type][ABIL_DESTCAP] : (s)->max_destruct)
- X#define Max_speed(s) ( ((s)->type==OTYPE_FACTORY) ? Shipdata[(s)->type][ABIL_SPEED] : (s)->max_speed)
- X#define Max_crystals(s) (15)
- X#define Cost(s) ( ((s)->type==OTYPE_FACTORY) ? 2*(s)->build_cost*(s)->on + Shipdata[(s)->type][ABIL_COST ] : (s)->build_cost)
- X#define Mass(s) ( ((s)->type==OTYPE_FACTORY) ? 100.0 : (s)->base_mass)
- X#define Sight(s) ( ((s)->type==OTYPE_PROBE) || (s)->popn)
- X#define Retaliate(s) ( (s)->retaliate)
- X#define Size(s) ( ((s)->type==OTYPE_FACTORY) ? ship_size(s) : (s)->size)
- X#define Repair(s) ( ((s)->type==OTYPE_FACTORY) ? (s)->on : Max_crew(s))
- X
- Xextern placetype Getplace();
- Xextern char *Dispplace(),*Dispshiporbits(),*prin_ship_orbits(),
- X *prin_aimed_at(), *prin_ship_dest();
- Xextern int Shipdata[NUMSTYPES][NUMABILS];
- Xextern char Shipltrs[];
- Xextern char *Shipnames[];
- Xextern float tele_range(), gun_range(), getmass();
- X
- XEXTERN shiptype **ships;
- XEXTERN shiptype *shipptr;
- X
- END_OF_FILE
- if test 7935 -ne `wc -c <'server/ships.h'`; then
- echo shar: \"'server/ships.h'\" unpacked with wrong size!
- fi
- # end of 'server/ships.h'
- echo shar: End of archive 8 \(of 9\).
- cp /dev/null ark8isdone
- MISSING=""
- for I in 1 2 3 4 5 6 7 8 9 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 9 archives.
- rm -f ark[1-9]isdone ark[1-9][0-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
-